<?php

namespace App\Http\Controllers;

use App\Repositories\ProductRepository;
use Illuminate\Http\Request;

class ProductController extends Controller
{
    protected $product;

    public function __construct(ProductRepository $product)
    {
        $this->product = $product;
    }

    public function index()
    {
        $products = $this->product->paginate('15');
        return $this->success($products);
    }

    public function create(Request $request)
    {
        $this->product->create($request->all());
        return $this->success();
    }

    public function update(Request$request, $id)
    {
        $this->product->update($request->all(), $id);
        return $this->success();
    }

    public function delete($id)
    {
        $this->product->delete($id);
        return $this->success();
    }
}
